<!doctype html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Linux命令," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;scp是secure copy的简写，用于在Linux下进行远程拷贝文件的命令，和它类似的命令有cp，不过cp只是在本机进行拷贝不能跨服务器，而且scp传输是加密的。可能会稍微影响一下速度。当你服务器硬盘变为只读 read only system时，用scp可以帮你把文件移出来。另外，scp还非常不占资">
<meta name="keywords" content="Linux命令">
<meta property="og:type" content="article">
<meta property="og:title" content="Linux 命令- scp">
<meta property="og:url" content="https://hcldirgit.github.io/2017/09/03/2. Linux 命令/62. Linux 命令- scp/index.html">
<meta property="og:site_name" content="失落的乐章">
<meta property="og:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;scp是secure copy的简写，用于在Linux下进行远程拷贝文件的命令，和它类似的命令有cp，不过cp只是在本机进行拷贝不能跨服务器，而且scp传输是加密的。可能会稍微影响一下速度。当你服务器硬盘变为只读 read only system时，用scp可以帮你把文件移出来。另外，scp还非常不占资">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2017-09-01T08:37:34.177Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Linux 命令- scp">
<meta name="twitter:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;scp是secure copy的简写，用于在Linux下进行远程拷贝文件的命令，和它类似的命令有cp，不过cp只是在本机进行拷贝不能跨服务器，而且scp传输是加密的。可能会稍微影响一下速度。当你服务器硬盘变为只读 read only system时，用scp可以帮你把文件移出来。另外，scp还非常不占资">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://hcldirgit.github.io/2017/09/03/2. Linux 命令/62. Linux 命令- scp/"/>





  <title>Linux 命令- scp | 失落的乐章</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  




<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', '85*****1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?87980c**************99ec5e26fb5";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>











  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">失落的乐章</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">技术面前，永远都是学生。</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-message">
          <a href="/message" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-external-link"></i> <br />
            
            留言
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="https://hcldirgit.github.io/2017/09/03/2. Linux 命令/62. Linux 命令- scp/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="失落的乐章">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/0.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="失落的乐章">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Linux 命令- scp</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-09-03T01:57:34+08:00">
                2017-09-03
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;scp是secure copy的简写，用于在Linux下进行远程拷贝文件的命令，和它类似的命令有cp，不过cp只是在本机进行拷贝不能跨服务器，而且scp传输是加密的。可能会稍微影响一下速度。当你服务器硬盘变为只读 read only system时，用scp可以帮你把文件移出来。另外，scp还非常不占资源，不会提高多少系统负荷，在这一点上，rsync就远远不及它了。虽然 rsync比scp会快一点，但当小文件众多的情况下，rsync会导致硬盘I/O非常高，而scp基本不影响系统正常使用。</p>
<h2 id="1．命令格式"><a href="#1．命令格式" class="headerlink" title="1．命令格式"></a>1．命令格式</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">scp [参数] [原路径] [目标路径]</div></pre></td></tr></table></figure>
<h2 id="2．命令功能"><a href="#2．命令功能" class="headerlink" title="2．命令功能"></a>2．命令功能</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;scp是 secure copy的缩写, scp是linux系统下基于ssh登陆进行安全的远程文件拷贝命令。linux的scp命令可以在linux服务器之间复制文件和目录。</p>
<h2 id="3．命令参数"><a href="#3．命令参数" class="headerlink" title="3．命令参数"></a>3．命令参数</h2><ul>
<li>-1  强制scp命令使用协议ssh1  </li>
<li>-2  强制scp命令使用协议ssh2  </li>
<li>-4  强制scp命令只使用IPv4寻址  </li>
<li>-6  强制scp命令只使用IPv6寻址  </li>
<li>-B  使用批处理模式（传输过程中不询问传输口令或短语）  </li>
<li>-C  允许压缩。（将-C标志传递给ssh，从而打开压缩功能）  </li>
<li>-p 保留原文件的修改时间，访问时间和访问权限。  </li>
<li>-q  不显示传输进度条。  </li>
<li>-r  递归复制整个目录。  </li>
<li>-v 详细方式显示输出。scp和ssh(1)会显示出整个过程的调试信息。这些信息用于调试连接，验证和配置问题。   </li>
<li>-c cipher  以cipher将数据传输进行加密，这个选项将直接传递给ssh。   </li>
<li>-F ssh_config  指定一个替代的ssh配置文件，此参数直接传递给ssh。  </li>
<li>-i identity_file  从指定文件中读取传输时使用的密钥文件，此参数直接传递给ssh。    </li>
<li>-l limit  限定用户所能使用的带宽，以Kbit/s为单位。     </li>
<li>-o ssh_option  如果习惯于使用ssh_config(5)中的参数传递方式，   </li>
<li>-P port  注意是大写的P, port是指定数据传输用到的端口号   </li>
<li>-S program  指定加密传输时所使用的程序。此程序必须能够理解ssh(1)的选项。</li>
</ul>
<h2 id="4．使用实例"><a href="#4．使用实例" class="headerlink" title="4．使用实例"></a>4．使用实例</h2><h3 id="scp命令的实际应用概述："><a href="#scp命令的实际应用概述：" class="headerlink" title="scp命令的实际应用概述："></a>scp命令的实际应用概述：</h3><h4 id="从本地服务器复制到远程服务器："><a href="#从本地服务器复制到远程服务器：" class="headerlink" title="从本地服务器复制到远程服务器："></a>从本地服务器复制到远程服务器：</h4><h5 id="1-复制文件："><a href="#1-复制文件：" class="headerlink" title="(1) 复制文件："></a>(1) 复制文件：</h5><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;命令格式：  </p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">scp local_file remote_username@remote_ip:remote_folder</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;或者  </p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">scp local_file remote_username@remote_ip:remote_file</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;或者  </p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">scp local_file remote_ip:remote_folder</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;或者  </p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">scp local_file remote_ip:remote_file</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;第1,2个指定了用户名，命令执行后需要输入用户密码，第1个仅指定了远程的目录，文件名字不变，第2个指定了文件名</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;第3,4个没有指定用户名，命令执行后需要输入用户名和密码，第3个仅指定了远程的目录，文件名字不变，第4个指定了文件名   </p>
<h5 id="2-复制目录："><a href="#2-复制目录：" class="headerlink" title="(2) 复制目录："></a>(2) 复制目录：</h5><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;命令格式：  </p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">scp -r local_folder remote_username@remote_ip:remote_folder</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;或者  </p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">scp -r local_folder remote_ip:remote_folder</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;第1个指定了用户名，命令执行后需要输入用户密码；</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;第2个没有指定用户名，命令执行后需要输入用户名和密码；</p>
<h4 id="从远程服务器复制到本地服务器："><a href="#从远程服务器复制到本地服务器：" class="headerlink" title="从远程服务器复制到本地服务器："></a>从远程服务器复制到本地服务器：</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;从远程复制到本地的scp命令与上面的命令雷同，只要将从本地复制到远程的命令后面2个参数互换顺序就行了。</p>
<h3 id="实例1：从远处复制文件到本地目录"><a href="#实例1：从远处复制文件到本地目录" class="headerlink" title="实例1：从远处复制文件到本地目录"></a>实例1：从远处复制文件到本地目录</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">scp root@192.168.120.204:/opt/soft/nginx-0.5.38.tar.gz /opt/soft/</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># cd /opt/soft/</span></div><div class="line">[root@localhost soft]<span class="comment"># ll</span></div><div class="line">总计 80072</div><div class="line">drwxr-xr-x 12 root root     4096 09-21 18:40 fms3.5</div><div class="line">drwxr-xr-x  3 root root     4096 09-21 17:58 fms4.5</div><div class="line">drwxr-xr-x 10 root root     4096 10-30 17:15 jdk1.6.0_16</div><div class="line">drwxr-xr-x 10 root root     4096 09-17 19:27 jdk1.6.0_16.bak</div><div class="line">-rwxr-xr-x  1 root root 81871260 2009-12-21 jdk-6u16-linux-x64.bin</div><div class="line">drwxrwxrwx  2 root root     4096 09-21 01:16 mysql</div><div class="line">drwxr-xr-x  3 root root     4096 09-21 18:40 setup_file</div><div class="line">drwxr-xr-x  9 root root     4096 09-17 19:23 tomcat6.0.32</div><div class="line">drwxr-xr-x  9 root root     4096 2012-08-14 tomcat_7.0</div><div class="line">[root@localhost soft]<span class="comment"># scp root@192.168.120.204:/opt/soft/nginx-0.5.38.tar.gz /opt/soft/</span></div><div class="line">root@192.168.120.204<span class="string">'s password: </span></div><div class="line"><span class="string">nginx-0.5.38.tar.gz                                                                               100%  479KB 478.7KB/s   00:00    </span></div><div class="line"><span class="string">[root@localhost soft]# ll</span></div><div class="line"><span class="string">总计 80556</span></div><div class="line"><span class="string">drwxr-xr-x 12 root root     4096 09-21 18:40 fms3.5</span></div><div class="line"><span class="string">drwxr-xr-x  3 root root     4096 09-21 17:58 fms4.5</span></div><div class="line"><span class="string">drwxr-xr-x 10 root root     4096 10-30 17:15 jdk1.6.0_16</span></div><div class="line"><span class="string">drwxr-xr-x 10 root root     4096 09-17 19:27 jdk1.6.0_16.bak</span></div><div class="line"><span class="string">-rwxr-xr-x  1 root root 81871260 2009-12-21 jdk-6u16-linux-x64.bin</span></div><div class="line"><span class="string">drwxrwxrwx  2 root root     4096 09-21 01:16 mysql</span></div><div class="line"><span class="string">-rw-r--r--  1 root root   490220 03-15 09:11 nginx-0.5.38.tar.gz</span></div><div class="line"><span class="string">drwxr-xr-x  3 root root     4096 09-21 18:40 setup_file</span></div><div class="line"><span class="string">drwxr-xr-x  9 root root     4096 09-17 19:23 tomcat6.0.32</span></div><div class="line"><span class="string">drwxr-xr-x  9 root root     4096 2012-08-14 tomcat_7.0</span></div><div class="line"><span class="string">[root@localhost soft]#</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明</strong></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;从192.168.120.204机器上的/opt/soft/的目录中下载nginx-0.5.38.tar.gz 文件到本地/opt/soft/目录中</p>
<h3 id="实例2：从远处复制到本地"><a href="#实例2：从远处复制到本地" class="headerlink" title="实例2：从远处复制到本地"></a>实例2：从远处复制到本地</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">scp -r root@192.168.120.204:/opt/soft/mongodb /opt/soft/</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div></pre></td><td class="code"><pre><div class="line">[root@localhost soft]<span class="comment"># ll</span></div><div class="line">总计 80556</div><div class="line">drwxr-xr-x 12 root root     4096 09-21 18:40 fms3.5</div><div class="line">drwxr-xr-x  3 root root     4096 09-21 17:58 fms4.5</div><div class="line">drwxr-xr-x 10 root root     4096 10-30 17:15 jdk1.6.0_16</div><div class="line">drwxr-xr-x 10 root root     4096 09-17 19:27 jdk1.6.0_16.bak</div><div class="line">-rwxr-xr-x  1 root root 81871260 2009-12-21 jdk-6u16-linux-x64.bin</div><div class="line">drwxrwxrwx  2 root root     4096 09-21 01:16 mysql</div><div class="line">-rw-r--r--  1 root root   490220 03-15 09:11 nginx-0.5.38.tar.gz</div><div class="line">drwxr-xr-x  3 root root     4096 09-21 18:40 setup_file</div><div class="line">drwxr-xr-x  9 root root     4096 09-17 19:23 tomcat6.0.32</div><div class="line">drwxr-xr-x  9 root root     4096 2012-08-14 tomcat_7.0</div><div class="line">[root@localhost soft]<span class="comment"># scp -r root@192.168.120.204:/opt/soft/mongodb /opt/soft/</span></div><div class="line">root@192.168.120.204<span class="string">'s password: </span></div><div class="line"><span class="string">mongodb-linux-i686-static-1.8.5.tgz                                                               100%   28MB  28.3MB/s   00:01    </span></div><div class="line"><span class="string">README                                                                                            100%  731     0.7KB/s   00:00    </span></div><div class="line"><span class="string">THIRD-PARTY-NOTICES                                                                               100% 7866     7.7KB/s   00:00    </span></div><div class="line"><span class="string">mongorestore                                                                                      100% 7753KB   7.6MB/s   00:00    </span></div><div class="line"><span class="string">mongod                                                                                            100% 7760KB   7.6MB/s   00:01    </span></div><div class="line"><span class="string">mongoexport                                                                                       100% 7744KB   7.6MB/s   00:00    </span></div><div class="line"><span class="string">bsondump                                                                                          100% 7737KB   7.6MB/s   00:00    </span></div><div class="line"><span class="string">mongofiles                                                                                        100% 7748KB   7.6MB/s   00:01    </span></div><div class="line"><span class="string">mongostat                                                                                         100% 7808KB   7.6MB/s   00:00    </span></div><div class="line"><span class="string">mongos                                                                                            100% 5262KB   5.1MB/s   00:01    </span></div><div class="line"><span class="string">mongo                                                                                             100% 3707KB   3.6MB/s   00:00    </span></div><div class="line"><span class="string">mongoimport                                                                                       100% 7754KB   7.6MB/s   00:00    </span></div><div class="line"><span class="string">mongodump                                                                                         100% 7773KB   7.6MB/s   00:00    </span></div><div class="line"><span class="string">GNU-AGPL-3.0                                                                                      100%   34KB  33.7KB/s   00:00    </span></div><div class="line"><span class="string">[root@localhost soft]# ll</span></div><div class="line"><span class="string">总计 80560</span></div><div class="line"><span class="string">drwxr-xr-x 12 root root     4096 09-21 18:40 fms3.5</span></div><div class="line"><span class="string">drwxr-xr-x  3 root root     4096 09-21 17:58 fms4.5</span></div><div class="line"><span class="string">drwxr-xr-x 10 root root     4096 10-30 17:15 jdk1.6.0_16</span></div><div class="line"><span class="string">drwxr-xr-x 10 root root     4096 09-17 19:27 jdk1.6.0_16.bak</span></div><div class="line"><span class="string">-rwxr-xr-x  1 root root 81871260 2009-12-21 jdk-6u16-linux-x64.bin</span></div><div class="line"><span class="string">drwxr-xr-x  3 root root     4096 03-15 09:18 mongodb</span></div><div class="line"><span class="string">drwxrwxrwx  2 root root     4096 09-21 01:16 mysql</span></div><div class="line"><span class="string">-rw-r--r--  1 root root   490220 03-15 09:11 nginx-0.5.38.tar.gz</span></div><div class="line"><span class="string">drwxr-xr-x  3 root root     4096 09-21 18:40 setup_file</span></div><div class="line"><span class="string">drwxr-xr-x  9 root root     4096 09-17 19:23 tomcat6.0.32</span></div><div class="line"><span class="string">drwxr-xr-x  9 root root     4096 2012-08-14 tomcat_7.0</span></div><div class="line"><span class="string">[root@localhost soft]#</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明</strong></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;从192.168.120.204机器上的/opt/soft/中下载mongodb 目录到本地的/opt/soft/目录来。</p>
<h3 id="实例3：上传本地文件到远程机器指定目录"><a href="#实例3：上传本地文件到远程机器指定目录" class="headerlink" title="实例3：上传本地文件到远程机器指定目录"></a>实例3：上传本地文件到远程机器指定目录</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">scp /opt/soft/nginx-0.5.38.tar.gz root@192.168.120.204:/opt/soft/scptest</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div></pre></td><td class="code"><pre><div class="line">上传前目标机器的目标目录：</div><div class="line">[root@localhost soft]<span class="comment"># cd scptest/</span></div><div class="line">[root@localhost scptest]<span class="comment"># ll</span></div><div class="line">总计 0</div><div class="line">[root@localhost scptest]<span class="comment"># ll</span></div><div class="line"></div><div class="line">本地机器上传：</div><div class="line">[root@localhost soft]<span class="comment"># scp /opt/soft/nginx-0.5.38.tar.gz root@192.168.120.204:/opt/soft/scptest</span></div><div class="line">root@192.168.120.204<span class="string">'s password: </span></div><div class="line"><span class="string">nginx-0.5.38.tar.gz                                                                               100%  479KB 478.7KB/s   00:00    </span></div><div class="line"><span class="string">[root@localhost soft]# </span></div><div class="line"><span class="string"></span></div><div class="line"><span class="string">上传后目标机器的目标目录：</span></div><div class="line"><span class="string">[root@localhost scptest]# ll</span></div><div class="line"><span class="string">总计 484</span></div><div class="line"><span class="string">-rw-r--r-- 1 root root 490220 03-15 09:25 nginx-0.5.38.tar.gz</span></div><div class="line"><span class="string">[root@localhost scptest]#</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明</strong></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;复制本地opt/soft/目录下的文件nginx-0.5.38.tar.gz 到远程机器192.168.120.204的opt/soft/scptest目录</p>
<h3 id="实例4：上传本地目录到远程机器指定目录"><a href="#实例4：上传本地目录到远程机器指定目录" class="headerlink" title="实例4：上传本地目录到远程机器指定目录"></a>实例4：上传本地目录到远程机器指定目录</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">scp -r /opt/soft/mongodb root@192.168.120.204:/opt/soft/scptest</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div></pre></td><td class="code"><pre><div class="line">上传前目标机器的目标目录：</div><div class="line">[root@localhost ~]<span class="comment"># cd /opt/soft/scptest/</span></div><div class="line">[root@localhost scptest]<span class="comment"># ll</span></div><div class="line">总计 484</div><div class="line">-rw-r--r-- 1 root root 490220 03-15 09:25 nginx-0.5.38.tar.gz</div><div class="line">[root@localhost scptest]<span class="comment"># </span></div><div class="line">本地机器上传：</div><div class="line">[root@localhost ~]<span class="comment"># scp -r /opt/soft/mongodb root@192.168.120.204:/opt/soft/scptest</span></div><div class="line">root@192.168.120.204<span class="string">'s password: </span></div><div class="line"><span class="string">mongodb-linux-i686-static-1.8.5.tgz                                                               100%   28MB  28.3MB/s   00:01    </span></div><div class="line"><span class="string">README                                                                                            100%  731     0.7KB/s   00:00    </span></div><div class="line"><span class="string">THIRD-PARTY-NOTICES                                                                               100% 7866     7.7KB/s   00:00    </span></div><div class="line"><span class="string">mongorestore                                                                                      100% 7753KB   7.6MB/s   00:00    </span></div><div class="line"><span class="string">mongod                                                                                            100% 7760KB   7.6MB/s   00:01    </span></div><div class="line"><span class="string">mongoexport                                                                                       100% 7744KB   7.6MB/s   00:00    </span></div><div class="line"><span class="string">bsondump                                                                                          100% 7737KB   7.6MB/s   00:00    </span></div><div class="line"><span class="string">mongofiles                                                                                        100% 7748KB   7.6MB/s   00:00    </span></div><div class="line"><span class="string">mongostat                                                                                         100% 7808KB   7.6MB/s   00:01    </span></div><div class="line"><span class="string">mongos                                                                                            100% 5262KB   5.1MB/s   00:00    </span></div><div class="line"><span class="string">mongo                                                                                             100% 3707KB   3.6MB/s   00:00    </span></div><div class="line"><span class="string">mongoimport                                                                                       100% 7754KB   7.6MB/s   00:01    </span></div><div class="line"><span class="string">mongodump                                                                                         100% 7773KB   7.6MB/s   00:00    </span></div><div class="line"><span class="string">GNU-AGPL-3.0                                                                                      100%   34KB  33.7KB/s   00:00    </span></div><div class="line"><span class="string">[root@localhost ~]# </span></div><div class="line"><span class="string"></span></div><div class="line"><span class="string">上传后目标机器的目标目录：</span></div><div class="line"><span class="string">[root@localhost scptest]# ll</span></div><div class="line"><span class="string">总计 488</span></div><div class="line"><span class="string">drwxr-xr-x 3 root root   4096 03-15 09:33 mongodb</span></div><div class="line"><span class="string">-rw-r--r-- 1 root root 490220 03-15 09:25 nginx-0.5.38.tar.gz</span></div><div class="line"><span class="string">[root@localhost scptest]#</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明</strong></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;上传本地目录 /opt/soft/mongodb到远程机器192.168.120.204上/opt/soft/scptest的目录中去</p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Linux命令/" rel="tag"># Linux命令</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/09/03/2. Linux 命令/31. group 文件详解/" rel="next" title="/etc/group 文件详解">
                <i class="fa fa-chevron-left"></i> /etc/group 文件详解
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/09/03/2. Linux 命令/9. Linux 命令- cp/" rel="prev" title="Linux 命令- cp">
                Linux 命令- cp <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/0.png"
               alt="失落的乐章" />
          <p class="site-author-name" itemprop="name">失落的乐章</p>
           
              <p class="site-description motion-element" itemprop="description">失落的乐章的Blog</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/">
                <span class="site-state-item-count">627</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">38</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/hcldirgit" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#1．命令格式"><span class="nav-number">1.</span> <span class="nav-text">1．命令格式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2．命令功能"><span class="nav-number">2.</span> <span class="nav-text">2．命令功能</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3．命令参数"><span class="nav-number">3.</span> <span class="nav-text">3．命令参数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4．使用实例"><span class="nav-number">4.</span> <span class="nav-text">4．使用实例</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#scp命令的实际应用概述："><span class="nav-number">4.1.</span> <span class="nav-text">scp命令的实际应用概述：</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#从本地服务器复制到远程服务器："><span class="nav-number">4.1.1.</span> <span class="nav-text">从本地服务器复制到远程服务器：</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#1-复制文件："><span class="nav-number">4.1.1.1.</span> <span class="nav-text">(1) 复制文件：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#2-复制目录："><span class="nav-number">4.1.1.2.</span> <span class="nav-text">(2) 复制目录：</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#从远程服务器复制到本地服务器："><span class="nav-number">4.1.2.</span> <span class="nav-text">从远程服务器复制到本地服务器：</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例1：从远处复制文件到本地目录"><span class="nav-number">4.2.</span> <span class="nav-text">实例1：从远处复制文件到本地目录</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例2：从远处复制到本地"><span class="nav-number">4.3.</span> <span class="nav-text">实例2：从远处复制到本地</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例3：上传本地文件到远程机器指定目录"><span class="nav-number">4.4.</span> <span class="nav-text">实例3：上传本地文件到远程机器指定目录</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例4：上传本地目录到远程机器指定目录"><span class="nav-number">4.5.</span> <span class="nav-text">实例4：上传本地目录到远程机器指定目录</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">失落的乐章</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  





  

  

  

  

  

  

</body>
</html>
